package com.rogo.rogobox.views
{
	import com.rogo.mvc.sub.mediator.Mediator;
	import com.rogo.rogobox.AppFacade;
	import com.rogo.rogobox.views.components.GroupLogin;
	
	import flash.events.MouseEvent;
	
	import mx.core.UIComponent;
	import mx.events.FlexEvent;
	
	public class GroupLoginMediator extends Mediator
	{
		public function GroupLoginMediator(viewComponent:UIComponent)
		{
			super(NAME, viewComponent);
		}
		
		//--------------------------------------------------------------------------
		//
		//  Constants
		//
		//--------------------------------------------------------------------------
		
		public static const NAME:String = 'groupLoginMediator';
		
		//--------------------------------------------------------------------------
		//
		//  Variables
		//
		//--------------------------------------------------------------------------
		
		public function get view():GroupLogin
		{
			return viewComponent as GroupLogin;
		}
		
		//--------------------------------------------------------------------------
		//
		//  Overridden Methods
		//
		//--------------------------------------------------------------------------
		
		override public function onRegister():void
		{
			view.verifyBtn.addEventListener(MouseEvent.CLICK, btnAuthorize_clickHandler);
			view.verifyInput.addEventListener(FlexEvent.ENTER, verifyInput_enterHandler);
			view.loginBtn.addEventListener(MouseEvent.CLICK, loginBtn_clickHandler);
		}
		
		//--------------------------------------------------------------------------
		//
		//  Event Handlers
		//
		//--------------------------------------------------------------------------
		
		private function btnAuthorize_clickHandler(e:MouseEvent):void
		{
			sendNotification(AppFacade.LOGIN);
		}
		
		private function verifyInput_enterHandler(e:FlexEvent):void
		{
			sendNotification(AppFacade.VERIFY, view.verifyInput.text);
		}
		
		private function loginBtn_clickHandler(e:MouseEvent):void
		{
			sendNotification(AppFacade.VERIFY, view.verifyInput.text);
		}
		
	}
}